/*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* Alternatively, this software may be distributed under the terms of BSD
* license.
*
*
*
* Authors:                  zhoujian
* Email:            343600434@qq.com
* Date:         Mar-08-2024 13:36:28
*
*/


#ifndef __menu_H__
#define __menu_H__




#ifdef __cplusplus
extern "C" {
#endif

#include <stdint.h>


//#define QRENCODE_USE

//#define USER_MAX 12


typedef void (*screen_func)(uint8_t) ;
typedef void (*line_func)(uint8_t) ;

#define LINURM_DEBUG_ENUM
#ifdef LINURM_DEBUG_ENUM
typedef enum {
    NORMAL = 0,
    COUNT_CARD,
    SELECT_POS,
} MENU_OP_ENUM;
#endif

typedef struct {
    const uint8_t ok_max;
    const uint8_t type;
    const line_func show;
    const line_func clicked;
} LINE_T;

typedef struct {
    const screen_func screen_f;
    LINE_T line_t[3];
} MENU_T;

#define SCREEN_NUM 4

#define NO_13_SHEET

extern uint8_t flag_bt_enter_sleep;
extern volatile uint16_t system_1ms_cnt;
extern volatile uint16_t pre_system_cnt;
extern uint8_t bt_data_finish_flag;
extern uint8_t uart_log;
extern uint8_t uart_log_rotate;

extern volatile uint16_t pre_system_10ms_cnt;

void sys_delay(uint8_t t);
void sys_ms_delay(uint32_t start);

void wait_motor(void);
void wait_rotate_motor(void);
void enter_language(void);
void wait_util_rotate_start(void);
void start_right_shuffle();
void start_left_shuffle();
void stop_left_shuffle();
void stop_right_shuffle();
void start_left_shuffle_rev();
void start_right_shuffle_rev();


void stop_shuffle();


void wait_util_rotate_dec(void);
void wait_cycle(void);
void enter_quick_test_mode(void);

void main_menu(void);
void test_key(void);

void enter_menu_setting(void);
void menu_enter_long_setting(void);
void enter_count_card(void);

uint8_t get_key(void);
uint8_t wait_key_back(uint8_t t);
void show_led_people();

typedef struct {
    unsigned char times;
    unsigned char frequency;
    unsigned char curr_sec;
} BUZZER_CTRL;

void buzzer_init(void);
void buzzer_on(void);
void buzzer_off(void);
void  buzzer_start(unsigned char frequency, unsigned char times);
void enter_all_test(void);
void enter_send_motor(void);
void enter_rotate_motor(void);

uint8_t enter_charging(uint8_t show_vol);
void wait_motor_idle(void);


extern uint8_t uart_shuffle;
//#define save_settings_to_flash()

#ifdef LINURM_DEBUG_MOTOR_TEST
void motor_test(void);

#endif
#ifdef LINURM_DEBUG_BATTERY_TEST
void battery_test(void);

#endif

void enter_ble_update_firmware(void);
void enter_version(void);

extern volatile uint16_t send_card_timer;
extern volatile uint16_t cycle_timer;



#ifdef __cplusplus
}
#endif




#endif
